package dao

import (
	"WORKSPACE/models"
	"fmt"
)

func GetAllovertime() (error, []models.Overtime, int64) {
	var OvertimeData []models.Overtime
	//AttendanceData := []models.Attendance{{"1qwe",1,"1",1,1,1,1,1,}}
	var total int64
	fmt.Println(OvertimeData)
	err := db.Table("overtime").Order("Eno ASC").Count(&total).Find(&OvertimeData).Error
	fmt.Println(OvertimeData)
	return err, OvertimeData, total
}

func Addovertime(overtime models.Overtime) error {
	err := db.Table("overtime").Create(&overtime).Error
	return err
}

func Updateovertime(overtime models.Overtime) error {
	err := db.Table("overtime").Where("Eno = ? AND Odata = ?", overtime.Eno,overtime.Odata).Updates(overtime).Error
	return err
}

func Delovertime(eno string,odata string) error {
	err := db.Table("overtime").Where("Eno = ? AND Odata = ?", eno,odata).Delete(models.Overtime{}).Error
	return err
}